<?php include("/includes/header.php") ?>
<?php include("/includes/sidebar.php") ?>
<?php $id = base64_decode($_GET[trim(base64_encode("idroom"), '=')]); ?>

<?php
	$paidStatus = array(0 => "Occupier", 1 => "Checkout");
	$data_room = getRoom($id);
	$sql = "SELECT *, a.nama AS guest, b.nama AS agent, a.id AS idFO FROM front_office a LEFT JOIN agent b ON b.id = a.idagent WHERE a.idroom = '".$id."' ORDER BY Checkin";
	$query = mysql_query($sql);
?>

<div class="header">
	<span>
		<a href="fo-room-info.php?<?php echo $_SERVER["QUERY_STRING"]; ?>">
			<i class="fa fa-eye"></i> Room Info
		</a>
	</span>
	<span class="active">
		<a href="fo-room-activity-table.php?<?php echo $_SERVER["QUERY_STRING"]; ?>">
			<i class="fa fa-table"></i> Table View
		</a>
	</span>
	<span>
		<a href="fo-room-activity-calendar.php?<?php echo $_SERVER["QUERY_STRING"]; ?>">
			<i class="fa fa-calendar"></i> Calendar View
		</a>
	</span>
	<span>
		<a href="fo-room-activity-graph.php?<?php echo $_SERVER["QUERY_STRING"]; ?>">
			<i class="fa fa-bar-chart-o"></i> Graph View
		</a>
	</span>
</div>

<div class="content row-fluid">
	<div class="span12 table-placer">
		<div class="alert alert-info"><h4>Room Activity - <?php echo $data_room["nama"]; ?> | <small>Table View</small></h4></div>
		<div class="row-fluid index-pos-placer">
			<table class="table table-striped table-bordered" id="data_table">
				<thead>
					<tr>
						<th>No</th>
						<th>Name</th>
						<th>Checkin Date</th>
						<th>Checkout Date</th>
						<th>Agent</th>
						<th>Status</th>
					</tr>
				</thead>
				<tbody>

			<?php
				$i = 1;
				while ($data = mysql_fetch_array($query)) {
					$data = validateData($data);
					extract($data);
					if ($agent == '') {
						$agent = '-';
					}
			?>
					<tr>
						<td><?php echo $i; ?></td>
						<td><a href="guests_details.php?<?php echo trim(base64_encode("id"), '=')."=".base64_encode($idFO); ?>"><?php echo $guest; ?></a></td>
						<td><?php echo date(  "l, F j Y", strtotime( $checkin ) )." at ".date(  "H:i", strtotime( $checkin ) ); ?></td>
						<td><?php echo date(  "l, F j Y", strtotime( $checkout ) )." at ".date(  "H:i", strtotime( $checkout ) ); ?></td>
						<td><?php echo $agent; ?></td>
						<td><?php echo $paidStatus[$is_paid]; ?></td>
					</tr>
			<?php
					$i++;
				}
			?>
				</tbody>
			</table>
		</div>
	</div>
</div>

<div class="footer">
</div>

<?php include("/includes/footer.php") ?>

<script type="text/javascript">
	$(document).ready(function() {
		$('#data_table').dataTable( {
			"sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>",
			"sPaginationType": "bootstrap",
			"aoColumns": [
				{ "sClass": "center", "bSearchable": false, "bSortable": false },
				{ "sClass": "center", "bSearchable": false, "bSortable": false},
				{ "sClass": "left", "bSearchable": true, "bSortable": true },
				{ "sClass": "left", "bSearchable": true, "bSortable": true },
				{ "sClass": "left", "bSearchable": true, "bSortable": true },
			],
			"oLanguage": {
				"sLengthMenu": "_MENU_ data per halaman"
			}
		})
	});
</script>